/**
 * @file sbc.h
 * @date 2020.7.28
 * @author zhiyuan,chen
 *
 * @defgroup
 * @ingroup
 * @brief 
 * @details
 *
 *
 * @{
 *
 *
 */

#ifndef __LIB_SBC_H__
#define __LIB_SBC_H__

#ifdef __cplusplus
extern "C"
{ /*}*/
#endif

/*********************************************************************
 * INCLUDES
 */


/*********************************************************************
 * MACROS
 */
#define LIB_SBC_FREQ_16000		0x00
#define LIB_SBC_FREQ_32000		0x01
#define LIB_SBC_FREQ_44100		0x02
#define LIB_SBC_FREQ_48000		0x03

/* blocks */
#define LIB_SBC_BLK_4		0x00
#define LIB_SBC_BLK_8		0x01
#define LIB_SBC_BLK_12		0x02
#define LIB_SBC_BLK_16		0x03

/* channel mode */
#define LIB_SBC_MODE_MONO		0x00
#define LIB_SBC_MODE_DUAL_CHANNEL	0x01
#define LIB_SBC_MODE_STEREO		0x02
#define LIB_SBC_MODE_JOINT_STEREO	0x03

/* allocation method */
#define LIB_SBC_AM_LOUDNESS		0x00
#define LIB_SBC_AM_SNR		0x01

/* subbands */
#define LIB_SBC_SB_4		0x00
#define LIB_SBC_SB_8		0x01

/*********************************************************************
 * TYPEDEFS
 */
typedef struct
{
	unsigned char frequency;
	unsigned char blocks;
	unsigned char subbands;
	unsigned char mode;
	unsigned char allocation;
	unsigned char bitpool;
}lib_sbc_config_t;
/*********************************************************************
 * EXTERN VARIABLES
 */


/*********************************************************************
 * EXTERN FUNCTIONS
 */
#if (LIB_MSBC_BLUEDROID)
/**
 * @brief msbc codec_init
 *
 * @param[in] msbc, sbc or msbc
 *
 * @return None
 **/
void codec_init(unsigned char msbc, unsigned char bitpool);

/**
 * @brief sbc encoder pcm
 *
 * @param[in] input pcm data
 * @param[in] input_len pcm len
 * @param[in] output output data, the sbc stream data
 * @param[in] outlen input the max out len
 *
 * @return outlen len
 **/
int codec_encode(const unsigned char *input, unsigned short input_len, void* output, unsigned short output_len);
#endif

#if (LIB_SBC_BLUEZ==1 || LIB_SBC_BLUEDROID == 1)
/**
 * @brief sbc init
 *
 * @param[in] config @lib_sbc_config_t
 *
 * @return None
 **/
void lib_sbc_init(lib_sbc_config_t* config);

/**
 * @brief sbc uninit
 *
 * @return None
 **/
void lib_sbc_uninit(void);

/**
 * @brief sbc encoder pcm
 *
 * @param[in] pcmdata pcm data
 * @param[in] pcmlen pcm len
 * @param[in] output output data, the sbc stream data
 * @param[in/out] outlen input the max out len, and return the real out len
 *
 * @return None
 **/
void lib_sbc_encoder(unsigned char* pcmdata, unsigned short pcmlen, unsigned char* output, unsigned short *outlen);

#endif
#ifdef __cplusplus
/*{*/ }
#endif

#endif

/** @} */
